<?php
/**
 * @filesource startup.php
 * @package ShortUrl 
 */

set_time_limit(0);
ini_set('memory_limit', '512M');

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__)) );

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

defined('DS') 
	|| define('DS', DIRECTORY_SEPARATOR);
defined('APPLICATION_LIBPATH')
    || define('APPLICATION_LIBPATH', APPLICATION_PATH.DS.'library' );

//Display PHP errors
if( FALSE !== strrpos(APPLICATION_ENV,'production') ){
	error_reporting(0);
}else if( FALSE !== strrpos(APPLICATION_ENV,'staging') ) {
	error_reporting(E_ALL & ~(E_STRICT | E_NOTICE));
}else{
	error_reporting(-1);
}

// 设置默认的时区
date_default_timezone_set('Asia/Shanghai');

//配置数组
include_once APPLICATION_PATH.DS.'configs'.DS.APPLICATION_ENV.'.inc.php';

// 检测SPL autoload, 定义常量
if (!function_exists('spl_autoload_register')){
  exit('peck failed: spl_autoload does not exist in this PHP installation.');
}
if(false === spl_autoload_functions()){
  if( function_exists('__autoload') ){
    spl_autoload_register('__autoload',false);
  }
}
spl_autoload_extensions('.php,.class.php');
spl_autoload_register('spl_autoload');

//设置常量
$includePaths = $GLOBALS['__configs']['includePaths'];
if( is_array($includePaths) && 0<count($includePaths) ){
    set_include_path( '.'.PATH_SEPARATOR.implode(PATH_SEPARATOR, $includePaths) );
}


//[非Web应用 注视]// 禁用 magic quote
//@set_magic_quotes_runtime(0);
//// 处理被 magic quotes 自动转义过的数据
//if (get_magic_quotes_gpc()){
	//$in = array(& $_GET, & $_POST, & $_COOKIE, & $_REQUEST);
	//while (list ($k, $v) = each($in)){
		//foreach ($v as $key => $val){
            //if (! is_array($val)){
                //$in[$k][$key] = stripslashes($val);
                    //continue;
            //}
               //$in[] = & $in[$k][$key];
		//}
	//}
	//unset($in);
//}

 
